/*
	This file is part of Posixcpp library.

	Posixcpp library is free software: you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation, either version 3 of
	the License, or (at your option) any later version.

	Posixcpp library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU LesserGeneral Public
	License along with Posixcpp library. If not, see
	<http://www.gnu.org/licenses/>.
 */

/**
 * @file posix_io_file.hpp
 * 
 */

#ifndef POISX_IO_FILE_HPP
#define	POISX_IO_FILE_HPP

#include "posix_io_handle.hpp"

#include <string>

namespace posix {
namespace io {

class IFile {
public:
    ~IFile () {
    }
    
    virtual void create () = 0;
    
    virtual void create (
      const std::string &fileName,
      Mode mode = 0) = 0;
    
    virtual void open () = 0;
    
    virtual void open (
      const std::string &fileName,
      Mode mode = 0) = 0;
};

class File : public Handle, public IFile {
public:
    File();
    File( const std::string &fileName );
    /**
     * Create file
     */
    void create () override;

    void create(
      const std::string& fileName,
      Mode mode ) override;

    /**
     * Open file
     */
    void open() override;
    void open(
      const std::string& fileName,
      Mode mode) override;

    
    void setFileName (const std::string &str) {
        m_fileName = str;
    }
    const std::string &fileName () const {
        return m_fileName;
    }
    
    void setAccessMode (AccessMode_t newVal) {
        m_accessMode = newVal;
    }
    AccessMode_t accessMode () const {
        return m_accessMode;
    }
    
    void setMode (Mode newVal) {
        m_mode = newVal;
    }
    Mode mode () const {
        return m_mode;
    }
    
    int customFlags() const {
        return m_customFlags;
    }
    void setCustomFlags(int newVal) {
        m_customFlags = newVal;
    }
    
private:
    std::string m_fileName;
    AccessMode_t m_accessMode;
    int m_customFlags;
    Mode m_mode;
};

}
}

#endif	/* POISX_IO_FILE_HPP */
